@extends('backend/layouts/default')
@section('title')
Danh sách Blog
@stop
@section('content')
<h3>
    <span class="glyphicon glyphicon-user"></span> Quản lý Tin

    <a href="{{ route('create/video/admin') }}" class="btn btn-xs btn-default"><i class="icon-plus-sign icon-white"></i> Tạo
        mới</a>
</h3>
<div class="box">
    <div class="box-header">
    </div>
    <!-- /.box-header -->
    <div class="box-body">
        <div>
            <form method="get" action="" autocomplete="off" role="form" class="form-inline">
                <!-- CSRF Token -->
                <input type="hidden" name="_token" value="{{ csrf_token() }}"/>

                <div class="form-group {{ $errors->has('key') ? 'has-error' : '' }}">
                    <input class="form-control" type="text" name="k" id="k"
                           value="{{ Input::old('k', (isset($data['appends']['k']) ? $data['appends']['k'] : '')) }}" placeholder="Tên"/>
                </div>
                <div class="form-group {{ $errors->has('groupId') ? 'has-error' : '' }}">
                    <?= Form::select('category', $data['categories'], Input::old('category', $data['appends']['category']), array('class' => 'form-control')) ?>
                </div>
                <input type="submit" class="btn btn-default btn-info" name="search" value="Tìm"/>
            </form>
            <hr/>
            <ul class="nav nav-tabs">
                <li
                {{ $data['appends']['withTrashed'] || !$data['appends']['onlyTrashed'] ? 'class="active"' : '' }} ><a
                    href="{{ URL::to('admin/videos?withTrashed=true') }}">Tất cả</a></li>
                <li
                {{ $data['appends']['onlyTrashed'] ? 'class="active"' : '' }}><a
                    href="{{ URL::to('admin/videos?onlyTrashed=true') }}">Không
                    kích hoạt</a></li>
            </ul>
        </div>
        <table class="table table-bordered table-striped table-hover">
            <thead>
            <tr>
                <th class="span1">@lang('admin/tones/table.id')</th>
                <th class="span6">@lang('admin/tones/table.name')</th>
                <th class="span2">Video</th>
                <th class="span2">Category</th>
                <th class="span2">@lang('admin/tones/table.created_at')</th>
                <th class="span2">@lang('table.actions')</th>
            </tr>
            </thead>
            <tbody>
            @if ($data['Videos']->count() >= 1)
            @foreach ($data['Videos'] as $video)
            <tr>
                <td>{{ $video->id }}</td>
                <td>{{ $video->title }}</td>
                <td>{{ $video->youtube }}</td>
                <td>{{ $video->c_title }}</td>
                <td>{{ $video->created_at->diffForHumans() }}</td>
                <td>
                    @if ( Sentry::getUser()->hasAnyAccess(['video','video.edit']) )
                    <a href="{{ route('update/video/admin', $video->id) }}"
                       class="btn btn-xs btn-default">@lang('button.edit')</a>
                    @endif
                    @if ( Sentry::getUser()->hasAnyAccess(['video','video.delete']) )
                    <a href="{{ route('delete/video/admin', $video->id) }}"
                       class="btn btn-xs btn-danger">@lang('button.delete')</a>
                    @endif
                </td>
            </tr>
            @endforeach
            @else
            <tr>
                <td colspan="5">Chưa có bản ghi nào.</td>
            </tr>
            @endif
            </tbody>
        </table>
        {{ $data['Videos']->links() }}
    </div>
</div>
@stop